Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Graphics /
Chapter 3 - Geometric Styles / Using Geometric Styles


Adding Standard Joins to a Shape

Two types of joins that you may frequently want to add to your shapes are the round join and the square join. Unlike the standard cap shapes, which you add yourself by creating a semicircle shape or a half-square shape, the standard join shapes are provided for you by QuickDraw GX.

To create a standard join shape, you set the join field of the join record to nil, which indicates that you are not providing a join shape, and you set the sharp join attribute or the curve join attribute, which indicates that you want QuickDraw GX to generate one of the standard joins for you.

Listing 3-12 shows how to add a sharp join to an angle shape.

Listing 3-12 Adding a sharp join to an angle shape

void CreateSharpJoin(void)
{
   gxShape  anAngleShape;

   static long angleGeometry[] = {1, /* number of contours */
                                  3, /* number of points */
                                  ff(20), ff(20), 
                                  ff(250), ff(60), 
                                  ff(20), ff(100)};
      
   gxJoinRecord theJoinRecord;

   anAngleShape = GXNewPolygons((gxPolygons *) angleGeometry);
   GXSetShapeFill(anAngleShape, gxOpenFrameFill);
      
   theJoinRecord.attributes = gxSharpJoin;
   theJoinRecord.join = nil;
   theJoinRecord.miter = gxPositiveInfinity; 

   GXSetShapeJoin(anAngleShape, &theJoinRecord);
      
   GXSetShapePen(anAngleShape, ff(15));
   
   GXDrawShape(anAngleShape);
   
   GXDisposeShape(anAngleShape);
}
Notice that this sample function sets the miter field to the constant value gxPositiveInfinity, which indicates the join should be as sharp as necessary.

Figure 3-57 shows the result of this sample function.

Figure 3-57 An angle with a sharp join

If you limit the miter of the sharp join, for example, with the code

theJoinRecord.miter = ff(1); /* scaled by pen width */
QuickDraw GX limits the distance between the actual corner of the contour as specified in the shape's geometry and the tip of the corner as actually drawn. Since miter is scaled by pen width, and the pen width in this example is 15, QuickDraw GX truncates the sharp join 15 points away from the actual corner of the geometry, as shown in
Figure 3-58.

Figure 3-58 An angle with a truncated sharp join

The sections "The Join Structure" on page 3-101 and "Join Attributes" on page 3-102 describe the join record structure and the join attributes in more detail, and the section "Getting and Setting Joins" beginning on page 3-129 describes the functions you can use to manipulate joins.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help